var ajaxtyp=1;//是否使用AJAX调用数据(默认调用,如果不调用设置为0)
var ajaxlisttype=1;//1.分类商品,2.新品,3.热卖,4.推荐,5.特价,6.缺货,7.补货,8.浏览更多,9.品牌,10.积分兑换商品,11.积分兑换礼品,12.搜索,13.新闻,14.公告
var tmp_div ="";
var iDefaultFilter = [];
var currentId = 0;//商品分类
var currentbid = 0;//商品品牌
var currentsortMethod=8;//默认排序方式(1商品名称↑,2商品名称↓,3商品品牌↑,4商品品牌↓,5价格从低到高,6价格从高到低,7发布时间从旧到新,8发布时间从新到旧,9商品人气从低到高,10商品人气从高到低,11购买次数从低到高,12购买次数从高到低)
var currentlistdisplay=1;//默认显示方式(1图文方式,2列表方式,3图屏方式)
var currentpagesize=12;//默认显示数量
var currentpage=1;//默认显示页数
var goodselsclassid=null;
var ajax_loading_wit=0;//延时提交时间
var ajax_class_func;
var hash_data="";
var pro_list_brand_total_no=1;//品牌是否需要返回统计信息
var pro_list_spec_total_no=1;//规格是否需要返回统计信息
var pro_list_props_total_no=1;//属性是否需要返回统计信息

var sp_link="-";//多个扩展属性或规格之间的连接符(AJAX调用时用-,非AJAX时用&)
var sp_link2="_";

// PageLoad function
  // This function is called when:
  // 1. after calling $.historyInit();
  // 2. after calling $.historyLoad();
  // 3. after pushing "Go Back" button of a browser
  //提交处理

  
function pageload(hash) {
	// hash doesn't contain the first # character.
	//alert("hash="+hash+",hash_data="+hash_data+"");
	clearTimeout(ajax_class_func);
	ajax_class_func=setTimeout(function(){
		if(hash_data==hash&&hash_data!=""){return false;}
		hash_data=hash;
		var postData={ajaxlisttype:ajaxlisttype,sortMethod:currentsortMethod,sortDisplay:currentlistdisplay};
		//alert("ajaxlisttype="+ajaxlisttype);
		switch(ajaxlisttype){
			case 1:{
					if(hash) {
						var paras = hash.split(sp_link);
						currentbid=paras[0];//品牌ID
						currentlistdisplay=paras[1];//显示方式
						currentsortMethod = paras[2];//排序方式
						currentpagesize = paras[3];//每页显示数量
						currentpage = paras[4];//第几页
						var propspost="";//扩展属性
						var specpost="";//规格
						var propsinput="";//输入项
						for(var ki=5;ki<paras.length;ki++){
							var tmp_id=paras[ki];
							if(tmp_id!=""){
								var tmp_idstr=tmp_id.split("_");
								switch(tmp_idstr[0]){
									case "p":{
										if(propspost!=""){propspost+=","}
										propspost+=tmp_id;
										break;
									}
									case "s":{
										if(specpost!=""){specpost+=","}
										specpost+=tmp_id;
										break;
									}
									case "ip":{
										var tmpsplit=tmp_idstr[1].split("=");
										postData["p_"+tmpsplit[0]]=tmpsplit[1];
									}
									
								}
							}
						}
						postData.propsid=propspost;
						postData.specid=specpost;
					}
					postData.ProductGroupID=currentId;
					postData.bid=currentbid;
					break;
			}
			case 2:
			case 3:
			case 4:
			case 5:
			case 6:
			case 7:
			case 8:
			case 10:
			case 12:{
				if(hash){
					var paras = hash.split(sp_link);
					currentlistdisplay=paras[0];//显示方式
					currentsortMethod = paras[1];//排序方式
					currentpagesize = paras[2];//每页显示数量
					currentpage = paras[3];//第几页
					//postData.sortDisplay=listdisplay;
					//postData.sortMethod=choice;
					//postData.pageSize=pageSize;
					//postData.Page=page;
				}
				break;
			}
			case 9:{//品牌商品
				if(hash){
					var paras = hash.split(sp_link);
					currentlistdisplay=paras[0];//显示方式
					currentsortMethod = paras[1];//排序方式
					currentpagesize = paras[2];//每页显示数量
					currentpage= paras[3];//第几页
				}
				postData.ProductGroupID=currentId;
				postData.bid=currentbid;
				break;
			}
			
		}
		postData.sortDisplay=currentlistdisplay;
		postData.sortMethod=currentsortMethod;
		postData.pageSize=currentpagesize;
		postData.Page=currentpage;
		postData.btotalno=pro_list_brand_total_no;
		postData.spectotalno=pro_list_spec_total_no;
		postData.propstotalno=pro_list_props_total_no;		
		//postData.
/*		if($("#listdisplay")[0]){$("#listdisplay").val(listdisplay);}
		if($("#sortMethod")[0]){$("#sortMethod").val(choice);}
		if($("#pagesize")[0]){$("#pagesize").val(pageSize);}*/
		//alert($.param(postData));
		ajax_tip_loadno=true;
		showProductList();
		$.get(lodo_web_path+"ProductsHtmlGeneratorHandler.asp?bn="+Math.random(), postData,function(data){
			//guanbi();
			$("#ProductList_loadding").hide();
			$("#ProductListLayer").html(data).show();
		});
	},ajax_loading_wit);
	

}

  //url初始化
  function initPage(){
    // Initialize history plugin.
    // The callback is called at once by present location.hash. 
    $.historyInit(pageload);
    // set onlick event for buttons
/*    $("a[rel='history']").click(function(){
      //
      var hash = this.href;
      hash = hash.replace(/^.*#/, '');
      // moves to a new page. 
      // pageload is called at once. 
      $.historyLoad(hash);
      return false;
    });*/
  }
	
	//设置要提交的信息
   function loadCompoundURL(brandID,propsid,specid){
        var strUrl="";
		var weburl="";
		if(ajaxtyp!=1){
			brandID="bid="+brandID;
			currentlistdisplay="sortDisplay="+currentlistdisplay;
			currentsortMethod="sortMethod="+currentsortMethod;
			currentpagesize="pageSize="+currentpagesize;
			currentpage="page="+currentpage;
		}
		switch(ajaxlisttype){
			case 1:{
				//品牌-显示方式-排序方式-每页显示数量-第几页-扩展属性-规格-扩展属性的输入值
				strUrl = brandID + sp_link+currentlistdisplay+sp_link + currentsortMethod + sp_link + currentpagesize + sp_link + currentpage;
				if(ajaxtyp!=1){
					if(propsid!=""){strUrl+=sp_link+propsid;}
					if(specid!=""){strUrl+=sp_link+specid;}
				}else{
					if(propsid!=""){
						propsid=propsid.replaceAll(sp_link,"[.]");
					}
					if(specid!=""){
						specid=specid.replaceAll(sp_link,"[.]");
					}
					strUrl+=sp_link+propsid+sp_link+specid;
				}
				var props_input="";
				$(iDefaultFilter).each(function(){
					if(props_input!=""){props_input+=sp_link}
					props_input+="i"+this.id+"="+this.name+""
				});
				if(props_input!=""){
					if(ajaxtyp==1){props_input=props_input.replaceAll(sp_link,"[.]");}
					strUrl+=sp_link+props_input;
				}
				weburl=lodo_web_path+"class.asp?id="+currentId+"&";
				break;
			}
			case 2:
			case 3:
			case 4:
			case 5:
			case 6:
			case 7:
			case 8:
			case 10:{
				//显示方式-排序方式-每页显示数量-第几页-分类
				strUrl=currentlistdisplay+sp_link + currentsortMethod + sp_link + currentpagesize + sp_link + currentpage//;+sp_link+currentId;
				weburl="?";
				break;
			}
			case 12:{
				//显示方式-排序方式-每页显示数量-第几页-分类
				strUrl=currentlistdisplay+sp_link + currentsortMethod + sp_link + currentpagesize + sp_link + currentpage//;+sp_link+currentId;
				weburl="";
				var SelGClass=jQuery.url.param("SelGClass");
				var SelB=jQuery.url.param("SelB");
				var Min_money=jQuery.url.param("Min_money");
				var Max_money=jQuery.url.param("Max_money");
				var Wordstr=jQuery.url.param("Wordstr");
				var Gstr=jQuery.url.param("Gstr");
				if(SelGClass!=undefined&&SelGClass!=""){
					weburl+="SelGClass="+SelGClass+"&"
				}
				if(SelB!=undefined&&SelB!=""){
					weburl+="SelB="+SelB+"&"
				}
				if(Min_money!=undefined&&Min_money!=""){
					weburl+="Min_money="+Min_money+"&"
				}
				if(Max_money!=undefined&&Max_money!=""){
					weburl+="Max_money="+Max_money+"&"
				}
				if(Wordstr!=undefined&&Wordstr!=""){
					weburl+="Wordstr="+Wordstr+"&"
				}
				if(Gstr!=undefined&&Gstr!=""){
					weburl+="Gstr="+Gstr+"&"
				}
				weburl="?"+weburl;
				break;
			}
			case 9:{//品牌商品
				//显示方式-排序方式-每页显示数量-第几页-分类
				strUrl=currentlistdisplay+sp_link + currentsortMethod + sp_link + currentpagesize + sp_link + currentpage//;+sp_link+currentId;
				weburl="?bid="+currentbid+"&cid="+currentId+"&";
				break;
			}
		}
		if(ajaxtyp==1){
			$.historyLoad(strUrl);
		}else{
			location.href=weburl+strUrl;
		}
   }
    
	
    function showProductList(groupID){
		$("#ProductList_loadding").show();
		//$("#ProductListLayer").hide();
		//$("#ProductListLayer").html("<br /><br />数据加载中......<br /><br /><img src='/js/ajax-loader.gif'>");
/*         if(ajaxlisttype==1&&groupID!=null&&groupID!=undefined){currentId = groupID;}
		 if(ajaxlisttype==1||ajaxlisttype==7){currentbid = $("#cbid").val();}
		 currentsortMethod=$("#sortMethod").val();
		 currentlistdisplay=$("#listdisplay").val();*/
    }
   
	function requestquerystring(formname){
		var strHref=location.href;
		var intPos = strHref.indexOf("?");
		var strRight = strHref.substr(intPos + 1);
		var arrTmp = strRight.split("&");
		for(var i = 0; i < arrTmp.length; i++)
		{
		var arrTemp = arrTmp[i].split("=");
		if(arrTemp[0].toUpperCase() == formname.toUpperCase()) return arrTemp[1];
		}
		return "";
	}

	function onpsize(e){
		$("#pagesize").val(e.value);
		onFilterAndSort();
	}

    //--------- START 排序和过虑 -----------------
    function onFilterAndSort(type,groupID){
        //if ($("#tmpImg")[0]){$("#tmpImg").show();}else{$("#ProductListLayer").html("<br /><br />数据加载中......<br /><br /><img src='/js/ajax-loader.gif'>");}
		
		if(groupID==null){groupID=$("#classId").val();}
		var listdisplay="";//默认显示方式
        var choice = "";//默认排序方式
        var pageSize = 12;
		var brandID=0;
		if($("#cbid")[0]){brandID=$("#cbid").val();}
		if($("#listdisplay")[0]){listdisplay=$("#listdisplay").val();}
        if($("#pagesize")[0]){pageSize =$("#pagesize").val();}
		if($("#sortMethod")[0]){choice =$("#sortMethod").val();}
		if(type!=null){$("#sortMethod").val(type);choice=type;}
	 	loadCompoundURL(groupID,brandID,listdisplay, choice, pageSize);

    }
    //--------- END 排序和过虑 -----------------
    
	//
	function onSelectedFilter(t_listdisplay,type,t_pagesize,page){
		if(t_listdisplay!=null&&t_listdisplay!=undefined&&Number(t_listdisplay)!=NaN){currentlistdisplay=t_listdisplay;}
		if(type!=null&&type!=undefined&&Number(type)!=NaN){currentsortMethod=type;}
		if(t_pagesize!=null&&t_pagesize!=undefined&&Number(t_pagesize)!=NaN){currentpagesize=t_pagesize;}
		if(page!=null&&page!=undefined&&Number(page)!=NaN){currentpage=page;}
		if(ajaxtyp!=1){sp_link="&";sp_link2="=";}
		switch(ajaxlisttype){
			case 1:{//分类
				var brandid="0";//品牌Id
				var propsid="";//扩展属性
				var specid="";//规格
				//搜索框
				iDefaultFilter=[];
				$("#MultiSearchform ul>li[sen=true]").each(function(){
					var sid=$(this).attr("sid");
					var sval=$("#"+sid).val();
					if(sval!=""){
						iDefaultFilter.push({id:sid,name:sval});
					}
				});
				
				//竖型
				$(".goods_screening_list>div.goods_screening_info ul[gsid][typ]").each(function(){
					var typ=$(this).attr("typ");
					var gsid=$(this).attr("gsid");
					var selectedall=$(this).find("li>label>input:checkbox:checked#ch_screening_all_"+gsid+"");
					if(!selectedall[0]){
						var selectedch=$(this).find("li>label>input:checkbox:checked[name='ch_goods_screening_"+gsid+"']");
						switch (typ){
							//品牌
							case "brand":{
								if(selectedch.size()>0){
									brandid="";
									selectedch.each(function(){
										if(brandid!=""){brandid+=",";}
										brandid+=$(this).val().replaceAll(sp_link,"[^]");
									});
								}
								break;
							}
							//扩展属性
							case "props":{
								if(selectedch.size()>0){
									if(propsid!=""){propsid+=sp_link;}
									propsid+=gsid;
									var tmp_propsid="";
									selectedch.each(function(){
										if(tmp_propsid!=""){tmp_propsid+="_";}
										tmp_propsid+=$(this).val().replaceAll(sp_link,"[^]");
									});
									propsid+=sp_link2+tmp_propsid;
								}
								break;
							}
							//规格
							case "spec":{
								if(selectedch.size()>0){
									if(specid!=""){specid+=sp_link;}
									specid+="s_"+gsid;
									var tmp_specid="";
									selectedch.each(function(){
										if(tmp_specid!=""){tmp_specid+="_";}
										tmp_specid+=$(this).val().replaceAll(sp_link,"[^]");
									});
									specid+=sp_link2+tmp_specid;
								}
								break;
							}
						}
					}
					
				});
				//平铺
				$(".goods_screening_list_2").each(function(){
					var typ=$(this).attr("typ");
					var gsid=$(this).attr("gsid");
					var totalselected=$(this).find("ul>li>a");
					var selectedch=$(this).find("ul>li>a.selected");
					if(totalselected.size()!=selectedch.size()){
						switch (typ){
							//品牌
							case "brand":{
								if(selectedch.size()>0){
									brandid="";
									selectedch.each(function(){
										if(brandid!=""){brandid+=",";}
										brandid+=$(this).attr("sid").replaceAll(sp_link,"[^]");
									});
								}
								break;
							}
							//扩展属性
							case "props":{
								if(selectedch.size()>0){
									if(propsid!=""){propsid+=sp_link;}
									propsid+=gsid;
									var tmp_propsid="";
									selectedch.each(function(){
										if(tmp_propsid!=""){tmp_propsid+="_";}
										tmp_propsid+=$(this).attr("sid").replaceAll(sp_link,"[^]");
									});
									propsid+=sp_link2+tmp_propsid;
								}
								break;
							}
							//规格
							case "spec":{
								if(selectedch.size()>0){
									if(specid!=""){specid+=sp_link;}
									specid+="s_"+gsid;
									var tmp_specid="";
									selectedch.each(function(){
										if(tmp_specid!=""){tmp_specid+="_";}
										tmp_specid+=$(this).attr("sid").replaceAll(sp_link,"[^]");
									});
									specid+=sp_link2+tmp_specid;
								}
								break;
							}
						}
					}
				});
				
				//伸缩
				$(".goods_screening_list_3>div.goods_screening_info>ul>li>a.selected").each(function(){
					var gsid=$(this).parent().parent().parent().parent().attr("gsid");
					var typ=$(this).parent().parent().parent().parent().attr("typ");
					var sid=$(this).attr("sid").replaceAll(sp_link,"[^]");
					switch(typ){
						case "brand":{
							brandid=sid;
							break;
						}
						case "props":{
							if(propsid!=""){propsid+=sp_link;}
							propsid+=gsid+sp_link2+sid;
							break;
						}
						case "spec":{
							if(specid!=""){specid+=sp_link;}
							specid+="s_"+gsid+sp_link2+sid;
							break;
						}
					}
				});
				//下拉
				$(".goods_screening_list_4>select>option[value!='0']:selected").each(function(){
					var gsid=$(this).parent().parent().attr("gsid");
					var typ=$(this).parent().parent().attr("typ");
					var sid=$(this).val().replaceAll(sp_link,"[^]");
					switch(typ){
						case "brand":{
							brandid=sid;
							break;
						}
						case "props":{
							if(propsid!=""){propsid+=sp_link;}
							propsid+=gsid+sp_link2+sid;
							break;
						}
						case "spec":{
							if(specid!=""){specid+=sp_link;}
							specid+="s_"+gsid+sp_link2+sid;
							break;
						}
					}
				});
				
				//渐进式
				$(".goods_screening_list_5>div.goods_screening_info>ul>li>a.selected").each(function(){
					var gsid=$(this).parent().parent().parent().parent().attr("gsid");
					var typ=$(this).parent().parent().parent().parent().attr("typ");
					var sid=$(this).attr("sid").replaceAll(sp_link,"[^]");
					switch(typ){
						case "brand":{
							brandid=sid;
							break;
						}
						case "props":{
							if(propsid!=""){propsid+=sp_link;}
							propsid+=gsid+sp_link2+sid;
							break;
						}
						case "spec":{
							if(specid!=""){specid+=sp_link;}
							specid+="s_"+gsid+sp_link2+sid;
							break;
						}
					}
				})
				loadCompoundURL(brandid,propsid,specid);
				break;
			}
			case 2:{
				loadCompoundURL();
				break;
			}
			case 3:{
				loadCompoundURL();
				break;
			}
			case 4:{
				loadCompoundURL();
				break;
			}
			case 5:{
				loadCompoundURL();
				break;
			}
			case 6:{
				loadCompoundURL();
				break;
			}
			case 7:{
				loadCompoundURL();
				break;
			}
			case 8:{
				loadCompoundURL();
				break;
			}
			case 9:{//品牌
				loadCompoundURL();
				break;
			}
			case 10:{
				loadCompoundURL();
				break;
			}
			case 11:{
				loadCompoundURL();
				break;
			}
			case 12:{
				loadCompoundURL();
				break;
			}
			case 13:{
				
				break;
			}
			case 14:{
				
				break;
			}
		}
	}
    
    function clearClasslist(tabId){
        var tab = document.getElementById("tab"+tabId);
        for(var i = 0;i < tab.rows.length;i++){
            if(i != 0){
                var row = tab.rows[i];
                for(var j=0;j < row.cells.length;j++){
                    var cel = row.cells[j];
                    if (cel.id != null && document.getElementById("color"+ cel.id + "_" + tabId)!=null)
                        document.getElementById("color"+ cel.id + "_" + tabId).className = "normal";
                }
            }
        }
    }

var goods_class_search_fields=[];
function changestate(mNum){
	for(var i=0;i<=1;i++){
		$("#menu"+i).attr("class","BrandLeftMenu");
		$("#main"+i).hide();
	}
	$("#menu"+mNum).attr("class","classLeftMeun");
	$("#main"+mNum).show();
}

function upsearch(){

	onSelectedFilter();
}

/*function upsearch_url(){
	
	var props_input="";
	$("#MultiSearchform ul>li[sen=true]").each(function(){
		if(props_input!=""){props_input+="-"}
		props_input+="i"+this.id+"="+this.name+""
	});
	strUrl = brandID + "-"+currentlistdisplay+"-" + currentsortMethod + "-" + currentpagesize + "-" + currentpage+"-"+propsid+"-"+specid;
	if(props_input!=""){strUrl+="-"+props_input;}
	break;
}
*/
//列表页面初始加载
function goods_list_init(){
	switch(ajaxlisttype){
		case 1:{
			$("input:checkbox[name^='ch_screening_all_']").click(function(){
				var gsid=$(this).parent().parent().parent().attr("gsid");
				var selectedtotalch=$("input:checkbox:checked[name='ch_goods_screening_"+gsid+"']").size();
				var selectedtotalMax=$("input:checkbox[name='ch_goods_screening_"+gsid+"']").size();
				
				if(selectedtotalch==selectedtotalMax||$(this).attr("checked")){
					$("input:checkbox[name='ch_goods_screening_"+gsid+"']").attr("checked",false);
					$(this).attr("checked",true);
				}else{
					if(selectedtotalch<=0){
						$("input:checkbox[name='ch_goods_screening_"+gsid+"']").attr("checked",true);
						$(this).attr("checked",false);
					}
				}
/*				if($(this).attr("checked")){
					if(selectedtotalch==selectedtotalMax){
						$("input:checkbox[name='ch_goods_screening_"+gsid+"']").attr("checked",false);
					}else{
						if(selectedtotalch<=0){$("input:checkbox[name='ch_goods_screening_"+gsid+"']").attr("checked",true);}
					}
					
				}*/
				onSelectedFilter();
			}).focus(function(){this.blur();});
		
			$("input:checkbox[name^='ch_goods_screening_']").click(function(){
				var gsid=$(this).parent().parent().parent().attr("gsid");
				var totalch=$("input:checkbox[name='ch_goods_screening_"+gsid+"']").size();
				var selectedtotalch=$("input:checkbox:checked[name='ch_goods_screening_"+gsid+"']").size();
				if(totalch==selectedtotalch||selectedtotalch==0){
					$("#ch_screening_all_"+gsid+"").attr("checked",true);
					//$("input:checkbox:checked[name='ch_goods_screening_"+gsid+"']").attr("checked",false);
				}else{
					$("#ch_screening_all_"+gsid+"").attr("checked",false);
				}
				onSelectedFilter();
			}).focus(function(){this.blur();});
		
			$(".goods_screening_list_2>div.goods_screening_info>ul>li>a").click(function(){
				var gsid=$(this).parent().parent().parent().parent().attr("gsid");
				
				//var sel=$(this).attr("class")=="selected"?"":"selected";
				//$(this).attr("class",sel);
				$(this).toggleClass("selected");
				var selectedtotalnum=$(".goods_screening_list_2[gsid='"+gsid+"']>div.goods_screening_info>ul>li>a.selected").size();
				$("#clear_goods_screening_"+gsid+">a").hide();
				if(selectedtotalnum>0){$("#clear_goods_screening_"+gsid+">a.clear").show();}else{$("#clear_goods_screening_"+gsid+">a.all").show();}
				onSelectedFilter();		
			}).focus(function(){this.blur();});
			
			$(".clear_goods_screening>a.clear").click(function(){
				gsid=$(this).parent().parent().parent().attr("gsid");
				var t=$(this).parent().parent().parent().attr("t");
				$(".goods_screening_list_"+t+"[gsid='"+gsid+"']>div.goods_screening_info>ul>li>a.selected").removeClass("selected");
				$(".goods_screening_list_"+t+"[gsid='"+gsid+"']>div.goods_screening_info>ul>li>a[sid]").parent().show();
				$(this).hide();
				$(this).parent().find("a.all").show();
				onSelectedFilter();
			});
			
			//伸缩
			$(".goods_screening_list_3>div.goods_screening_top").click(function(){
				var gsid=$(this).parent().attr("gsid");
				var showno=$(this).attr("showno");
				$(".goods_screening_list_3[gsid!='"+gsid+"']>div.goods_screening_top[showno='1']").attr("showno",0).removeClass("dtselected");
				$(".goods_screening_list_3[gsid!='"+gsid+"']>div.goods_screening_info.ddselected").removeClass("ddselected").hide();
				var dd=$(this).next("div.goods_screening_info");
				if(showno=="1"){
					$(this).attr("showno",0);
					$(this).removeClass("dtselected");
					dd.removeClass("ddselected").hide();
				}else{
					$(this).attr("showno",1);
					$(this).addClass("dtselected");
					dd.addClass("ddselected").show();
				}
				return false;
			}).attr("showno",0);
			
			$(".goods_screening_list_3>div.goods_screening_info>ul>li>a").click(function(){
				var gsid=$(this).parent().parent().parent().parent().attr("gsid");
				var sid=$(this).attr("sid");
				var g_title=$(".goods_screening_list_3[gsid='"+gsid+"']>div.goods_screening_top");
				var tname;
				if(!$(this).hasClass("selected")){
					$(".goods_screening_list_3[gsid='"+gsid+"']>div.goods_screening_info>ul>li>a.selected").removeClass("selected");
					$(this).addClass("selected");
					tname=$(this).attr("tip");
					g_title.addClass("selected");
				}else{
					$(this).removeClass("selected");
					g_title.removeClass("selected");
					tname=$(".goods_screening_list_3>div.goods_screening_top>#clear_goods_screening_"+gsid+"").attr("tip");
				}
				$("#clear_goods_screening_"+gsid).html(tname);
				g_title.click();
				onSelectedFilter();
				return false;
			});
			//下拉
			$(".goods_screening_list_4>select").change(function(){
				onSelectedFilter();
			});
			
			//渐进式
			$(".goods_screening_list_5>div.goods_screening_info>ul>li>a").click(function(){
				var gsid=$(this).parent().parent().parent().parent().attr("gsid");
				var sid=$(this).attr("sid");
				if(!$(this).hasClass("selected")){
					$(this).addClass("selected").parent().show();
					$(".goods_screening_list_5[gsid='"+gsid+"']>div.goods_screening_info>ul>li>a[sid!='"+sid+"']").parent().hide();
				}else{
					$(this).removeClass("selected");
					$(".goods_screening_list_5[gsid='"+gsid+"']>div.goods_screening_info>ul>li>a[sid]").parent().show();
				}
				onSelectedFilter();
				return false;
			});
			
			//showProductList();
			break;
		}
		case 2:{//新品
			
			break;
		}
		case 3:{//热卖
			
			break;
		}
		case 4:{//推荐
			
			break;
		}
		case 5:{//特价
			
			break;
		}
		case 6:{//'缺货
			
			break;
		}
		case 7:{//补货

			break;
		}
		case 8:{//浏览更多
			
			break;
		}
		case 9:{//品牌
				$("#brand_class_list>li[cid]").click(function(){
					$("#brand_class_list>li[cid]").removeClass("selected");
					$(this).addClass("selected");
					currentId=$(this).attr("cid");
					onSelectedFilter();
					return false;
				});
				//showProductList();
			break;
		}
		case 10:{//积分兑换商品
			
			break;
		}
		case 11:{//积分兑换礼品
			
			break;
		}
		case 12:{//搜索
			
			break;
		}
		case 13:{//新闻
			
			break;
		}
		case 14:{//公告
			
			break;
		}
	}
	if(ajaxtyp==1){initPage();}
}

function load_goods_list(){
	var url="";
	$(".goods_screening_list>ul[gsid]").each(function(){
		var gsid=$(this).attr("gsid");
		var typ=$(this).attr("typ");
		var idstr=0;
		var totalch=$("input:checkbox[name='ch_goods_screening_"+gsid+"']");
		var selectedcheckbox=$("input:checkbox:checked[name='ch_goods_screening_"+gsid+"']");
		if(!$("#ch_screening_all_"+gsid+"").attr("checked")&&totalch.size()>selectedcheckbox.size()){
			propsid="";
			selectedcheckbox.each(function(){
				if(idstr!=""){idstr+=","}
				idstr+=$(this).val();
			})
		}
		url+="&"+typ+"id="+idstr+"";
	});
	
	$(".goods_screening_list_2[gsid]").each(function(){
		var gsid=$(this).attr("gsid");
		var typ=$(this).attr("typ");
		var idstr="";
		$(this).find("ul>li>a.selected").each(function(){
			if(idstr!=""){idstr+=","}
			idstr+=$(this).attr("sid");
		});
		if(idstr!=""){
			url+=""+typ+"id="+idstr+"";
		}
	});
	url=lodo_web_path+"get_goodsclass.asp?act=list"+url;
	$.get(url,function(data){
		$("#goods_list").html(data);
	})
}

function set_search_totalnum(json){
	$(json.totalitems).each(function(){
		var typ=this.typ;
		var gsid=this.id;
		//alert("typ="+typ+",gsid="+gsid+",totalsum="+this.totalsum);
		$("#ch_screening_all_"+typ+"_"+gsid+"_total").html(this.totalsum);
		$(this.items).each(function(){
			$("#ch_goods_screening_"+typ+"_"+gsid+"_"+this.id+"_total").html(this.totalsum);
		});
	});
	
	$(json.props_input).each(function(){
		$(".goods_screening_list_6>ul>li[sid='"+this.id+"'][sen=true] input:text#"+this.id+"").val(this.name);
	});
	if($(json.breand).size()>0){
		var ifheight_b=$("#ifheight_b[typ='brand'][gsid='b']");
		if(ifheight_b[0]){
			var t=ifheight_b.attr("t");
			switch(t){
				case "1":{//竖型
					$("#ch_screening_all_b").attr("checked",false);
					$(json.breand).each(function(){
						ifheight_b.find("input:checkbox:checked#ch_goods_screening_b_"+this+"").attr("checked",true);
					});
					break;
				}
				case "2":{//平铺
					$("#clear_goods_screening_b>a.all").hide();
					$("#clear_goods_screening_b>a.clear").show();
					$(json.breand).each(function(){
						ifheight_b.find("div.goods_screening_info>ul>li>a[sid='"+this+"']").addClass("selected");
					});
					break;
				}
				case "3":{//伸缩
					ifheight_b.find("div.goods_screening_top").addClass("selected");
					$(json.breand).each(function(){
						ifheight_b.find("div.goods_screening_info>ul>li>a[sid='"+this+"']").addClass("selected");
					});
					var tname=ifheight_b.find("div.goods_screening_info>ul>li>a.selected:first").attr("tip");
					$("#clear_goods_screening_b").html(tname);
					break;
				}
				case "4":{//下拉
					$(json.breand).each(function(){
						ifheight_b.find("select>option[value='"+this+"']").attr("selected",true);
					})
					break;
				}
				case "5":{//渐进式
					$(json.breand).each(function(){
						ifheight_b.find("div.goods_screening_info>ul>li>a[sid='"+this+"']").addClass("selected");
					});
					ifheight_b.find("div.goods_screening_info>ul>li>a[sid]:not(.selected)").parent().hide();
					break;
				}
			}

		}
	}
	
	$(json.props).each(function(){
		var p_id=this.id;
		var ifheight_props=$("#ifheight_props_"+p_id);
		if(ifheight_props[0]&&$(this.items).size()>0){
			var t=ifheight_props.attr("t");
			switch(t){
				case "1":{
					ifheight_props.find("input:checkbox#ch_screening_all_"+p_id).attr("checked",false);
					$(this.items).each(function(){
						ifheight_props.find("input:checkbox[name='ch_goods_screening_"+p_id+"'][value='"+this.name+"']").attr("checked",true);
					});
					break;
				}
				case "2":{
					ifheight_props.find("#clear_goods_screening_"+p_id+">a.clear").show();
					ifheight_props.find("#clear_goods_screening_"+p_id+">a.all").hide();
					$(this.items).each(function(){
						ifheight_props.find("div.goods_screening_info>ul>li>a[sid='"+this.name+"']").addClass("selected");
					});
					break;
				}
				case "3":{
					ifheight_props.find("div.goods_screening_top").addClass("selected");
					$(this.items).each(function(){
						ifheight_props.find("div.goods_screening_info>ul>li>a[sid='"+this.name+"']").addClass("selected");
					});
					var tname=ifheight_props.find("div.goods_screening_info>ul>li>a.selected:first").attr("tip");
					ifheight_props.find("#clear_goods_screening_"+p_id).html(tname);
					break;
				}
				case "4":{
					$(this.items).each(function(){
						ifheight_props.find("select>option[value='"+this.name+"']").attr("selected",true);
					})
					break;
				}
				case "5":{
					$(this.items).each(function(){
						ifheight_props.find("div.goods_screening_info>ul>li>a[sid='"+this.name+"']").addClass("selected");
					});
					ifheight_props.find("div.goods_screening_info>ul>li>a[sid]:not(.selected)").parent().hide();
					break;
				}
			}
		}
	});
	
	$(json.spec).each(function(){
		var s_id=this.id;
		var ifheight_spec=$("#ifheight_spec_"+s_id);
		if(ifheight_spec[0]&&$(this.items).size()>0){
			var t=ifheight_spec.attr("t");
			switch(t){
				case "1":{
					ifheight_spec.find("input:checkbox#ch_screening_all_"+s_id).attr("checked",false);
					$(this.items).each(function(){
						ifheight_spec.find("input:checkbox[name='ch_goods_screening_"+s_id+"'][value='"+this.id+"']").attr("checked",true);
					});
					break;
				}
				case "2":{
					ifheight_spec.find("#clear_goods_screening_"+s_id+">a.clear").show();
					ifheight_spec.find("#clear_goods_screening_"+s_id+">a.all").hide();
					$(this.items).each(function(){
						ifheight_spec.find("div.goods_screening_info>ul>li>a[sid='"+this.id+"']").addClass("selected");
					});
					break;
				}
				case "3":{
					ifheight_spec.find("div.goods_screening_top").addClass("selected");
					$(this.items).each(function(){
						ifheight_spec.find("div.goods_screening_info>ul>li>a[sid='"+this.id+"']").addClass("selected");
					});
					var tname=ifheight_spec.find("div.goods_screening_info>ul>li>a.selected:first").attr("tip");
					ifheight_spec.find("#clear_goods_screening_"+s_id).html(tname);
					break;
				}
				case "4":{
					$(this.items).each(function(){
						ifheight_spec.find("select>option[value='"+this.id+"']").attr("selected",true);
					})
					break;
				}
				case "5":{
					ifheight_spec.find("#clear_goods_screening_"+s_id+">a.clear").show();
					ifheight_spec.find("#clear_goods_screening_"+s_id+">a.all").hide();
					$(this.items).each(function(){
						ifheight_spec.find("div.goods_screening_info>ul>li>a[sid='"+this.id+"']").addClass("selected");
					});
					ifheight_spec.find("div.goods_screening_info>ul>li>a[sid]:not(.selected)").parent().hide();
					break;
				}
			}
		}
	});	
	
}